package killerqueen.game.objects;

import killerqueen.game.interfaces.GameObject;

import org.jbox2d.collision.shapes.CircleShape;
import org.jbox2d.common.Vec2;
import org.jbox2d.dynamics.Body;
import org.jbox2d.dynamics.BodyDef;
import org.jbox2d.dynamics.BodyType;
import org.jbox2d.dynamics.FixtureDef;
import org.jbox2d.dynamics.World;
import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;

public class Circle implements GameObject {

	CircleShape cs;
	Body body;

	private float x;
	private float y;
	private float radius;

	public Circle() {
	}

	@Override
	public void init(World world, String id) {
		BodyDef bodyDef = new BodyDef();
		bodyDef.position = new Vec2(x, y);
		bodyDef.type = BodyType.DYNAMIC;
		body = world.createBody(bodyDef);

		cs = new CircleShape();
		cs.m_radius = radius;

		FixtureDef fixtureDef = new FixtureDef();
		fixtureDef.shape = cs;
		fixtureDef.density = 0;
		fixtureDef.friction = 0.01f;
		fixtureDef.restitution = 1f;

		body.createFixture(fixtureDef);
	}

	@Override
	public void paint(Graphics g) {

		g.pushTransform();

		Vec2 pos = body.getPosition();
		float angle = body.getAngle();
		g.translate(pos.x, pos.y);
		g.rotate(0, 0, (float) Math.toDegrees(+angle));
		org.newdawn.slick.geom.Circle circle = new org.newdawn.slick.geom.Circle(
				0, 0, cs.m_radius);

		g.setColor(Color.blue);
		g.fill(circle);
		g.setColor(Color.black);
		g.drawLine(0, 0, cs.m_radius, 0);
		g.draw(circle);

		g.popTransform();

	}

	@Override
	public void update(long delta) {
		// TODO Auto-generated method stub

	}

	@Override
	public void input(Input input) {
		// TODO Auto-generated method stub

	}

	public float getX() {
		return x;
	}

	public void setX(float x) {
		this.x = x;
	}

	public float getY() {
		return y;
	}

	public void setY(float y) {
		this.y = y;
	}

	public float getRadius() {
		return radius;
	}

	public void setRadius(float radius) {
		this.radius = radius;
	}

	@Override
	public void destroy(World world) {
		// TODO Auto-generated method stub
		
	}
}
